package com.techm.carpool.backend;

import android.content.Context;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.preference.PreferenceManager;

public class Settings {
    public static String USERNAME = "USERNAME";
    public static String USERNAME_DEFAULT = "";

    public static String EMAIL = "EMAIL";
    public static String EMAIL_DEFAULT = "";

    public static String PROFILEPIC = "EMAIL";
    public static String PROFILEPIC_DEFAULT = "";

    public static String STATUS = "EMAIL";
    public static int STATUS_DEFAULT = 0;

    public static SharedPreferences getSharedPreferences(Context context) {
        return PreferenceManager.getDefaultSharedPreferences(context);
    }

    public static String getUserName(Context context) {
        return getSharedPreferences(context).getString(USERNAME,
                USERNAME_DEFAULT);
    }

    public static String getEmail(Context context) {
        return getSharedPreferences(context).getString(EMAIL,
                EMAIL_DEFAULT);
    }

    public static String getProfilePic(Context context) {
        return getSharedPreferences(context).getString(PROFILEPIC,
                PROFILEPIC_DEFAULT);
    }

    public static int getStatus(Context context) {
        return getSharedPreferences(context).getInt(STATUS,
                STATUS_DEFAULT);
    }

    public static boolean isOnline(Context context) {
        ConnectivityManager cm = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        return cm.getActiveNetworkInfo() != null
                && cm.getActiveNetworkInfo().isConnectedOrConnecting();
    }

}